package cn.webrx;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Reg11 {
    public static void main(String[] args) {
        String a = "java8php123javascript6mysql88888html5";
        System.out.println(a);
        System.out.println(a.replaceAll("\\d{1,}", "-"));//贪婪模式
        System.out.println(a.replaceAll("\\d{1,}?", "-"));//?禁用贪婪
        System.out.println(a.replaceAll("\\d", "-"));

        String str = """
				<div>hello</div><div>java 15</div><div><p>java 15</p><span>java 8</p><div>java 16</div><div>javascript</div></div>
				""";


        //打印出<div>标签有java</div>
        Pattern p = Pattern.compile("<div>.*?java.*?</div>");
        Matcher m = p.matcher(str);
        while(m.find()) {
            System.out.println(m.group());
        }
    }
}
